|
|
|
|
|
|
|
If LCase$(ExecName) = "vb6.exe" Or _
LCase$(ExecName) = "vb5.exe" Or _
LCase$(ExecName) = "vb32.exe" Then
IsThisVB = True
End If
End Function |
|
|
|
|
|
|
|
|
The ExecName parameter is a string that is initialized to MAX_PATH + 1 bytes. This is long enough to contain the longest path supported by the system. The GetModuleFileName function loads the string with the full path of the executable that started the process. |
|
|
|
|
|
|
|
|
In this case, you don't care about the full pathonly the final executable name. The easiest way to strip off the rest of the path is to search for the last backslash character (or the colon character, in case the program is running from the root directory). Everything prior to and including the backslash is removed from the string using the Mid$ function. Finally, a case-insensitive comparison is performed against the three Visual Basic executable names. The function returns True if any of the executable names match. |
|
|
|
|
|
|
|
|
Add a simple project to the Visual Basic environment for testing purposes as shown in the IsThisVB group. |
|
|
|
|
|
|
|
|
' IsThisVBTest Sample Program
' Copyright © 1998 by Desaware Inc. All Rights Reserved
Option Explicit
Private Sub Form_Load()
Dim serverobject As New Server
If serverobject.IsThisVB Then
Label1.Caption = "Yes - it's VB"
Else
Label1.Caption = "No - it's not VB"
End If
End Sub |
|
|
|
|
|
|
|
|
For some reason, this program never detects that it is running within the Visual Basic environment. |
|
|
|
|
|
|
|
|
Your job is to figure out why. |
|
|
|
|
|